import { createStore } from 'vuex'

export default  createStore({
    //数据，相当于data
    state: {
        rest_Time:1,  //页面总计时  15分钟
        seatID:-1,  //桌号
        isStart:false,
        currentRound:-1,//当前是第几轮,
        isSeatValid:0, //本轮投资策略是否合法
        totalAssets:0,  //测试者当前的个人资产组合市值
        totalProfit:0, //当前累计收益
        currentProfit:0, //本轮收益
        userAssets: 0, //用户测试点数,
        fundTrend:[]
    },

    //里面定义方法，操作state方发
    mutations: {
        getTime(state){
            let timeNow = Date.now()
            state.rest_Time = timeNow + 1000 * 60 * 15 + 7000

        },
        resTime(state){
            if(state.isStart==false)
            {
                setInterval(this.calTime, 1000)
                console.log("开始全局倒计时15分钟")
                state.isStart = true
            }

        },
        calTime(state){
            state.rest_Time-=1000
            if(state.rest_Time==0)
            {
                this.$router.push({
                    name: 'end'
                })

            }
        }
    },
    // 操作异步操作mutation
    actions: {

    },
    modules: {

    },
})

